package com.rtf.framework.delaytask.impl;

import com.rtf.framework.dao.support.service.jpa.AppJPABaseDataServiceImpl;
import com.rtf.framework.delaytask.AppDelayTask;
import com.rtf.framework.delaytask.AppDelayTaskLog;
import com.rtf.framework.delaytask.AppDelayTaskLogService;
import com.rtf.framework.delaytask.impl.dao.AppDelayTaskLogDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedHashMap;
import java.util.Map;

@Slf4j
public class AppDelayTaskLogServiceImpl extends AppJPABaseDataServiceImpl<AppDelayTaskLog, AppDelayTaskLogDao>
        implements AppDelayTaskLogService {

    /**
     * 查询条件表达式
     */
    LinkedHashMap<String, String> expressionMap = new LinkedHashMap<String, String>() {
        private static final long serialVersionUID = 1L;
        {
        }
    };

    @Override
    public Map<String, String> getQueryExpressions() {
        return expressionMap;
    }

    @Transactional
    @Override
    public void saveDelayTaskLog(AppDelayTask delayTask) {
        AppDelayTaskLog appDelayTaskLog = new AppDelayTaskLog() ;
        // 设置任务属性
        appDelayTaskLog.setTaskId( delayTask.getId() ) ;
        appDelayTaskLog.setBusinessId( delayTask.getBusinessId() ) ;
        appDelayTaskLog.setRetryNum( delayTask.getRetryNum() ) ;
        appDelayTaskLog.setFailReason( delayTask.getFailReason() ) ;
        appDelayTaskLog.setSuccess( delayTask.getSuccess() ) ;
        appDelayTaskLog.setStartTime( delayTask.getStartTime() ) ;
        appDelayTaskLog.setEndTime( delayTask.getEndTime() ) ;

        this.save( appDelayTaskLog ) ;
    }
}